﻿using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using SocketPorxyServer;
using SuperSocket;
using SuperSocket.Command;
using SuperSocketProxy;
using SuperSocketProxy.Commands;


var host = SuperSocketHostBuilder.Create<SocketProxyPacket, ProxySwitchPipeFilter>()
                                 .UseHostedService<SocketProxyServer>()
                                 .UseSession<SocketProxySession>()
                                 .UseCommand(commandOptions => commandOptions.AddCommandAssembly(typeof(AuthUserPass).GetTypeInfo().Assembly))
                                 .UseClearIdleSession()
                                 .UseInProcSessionContainer()
                                 .ConfigureLogging(builder => builder.AddLog4Net())
                                 .ConfigureServices((context, service) =>
                                 {
                                     service.AddOptions<ProxyOptions>();
                                     service.Configure<ProxyOptions>(context.Configuration.GetSection("proxyOptions"));
                                 })
                                 .Build();
    
await host.RunAsync();